def go_square():
    turn_times = 0
    while front_is_clear():
        move()
        apple_detect()
        if wall_in_front():
            turn_left()
            turn_times += 1
            if turn_times == 4:
                break


def apple_detect():
    if object_here():
        take()
    else:
        pass


go_square()
